//
//  yunFuPhotoViewController.m
//  YuErmuYing
//
//  Created by Tiancheng on 16/9/14.
//  Copyright © 2016年 Tiancheng. All rights reserved.
//

#import "yunFuPhotoViewController.h"
#import "HttpRequest.h"
#import "allActivity.h"
#import "SVProgressHUD.h"

@interface yunFuPhotoViewController ()
@property(nonatomic,copy)NSMutableArray *json_Array;

@end

@implementation yunFuPhotoViewController
@synthesize json_Array;
static float progress = 0.0f;
- (void)viewDidLoad {
    [super viewDidLoad];
    [self getDataFromNet];
    progress=0.0f;
    [SVProgressHUD showWithStatus:@"加载中请稍后..."];
//    self.view.backgroundColor=[UIColor blueColor];

}
//从服务器获取数据
-(void)getDataFromNet
{
    NSString*urlString=[NSString stringWithFormat:@"http://112.74.114.1/Parenting/index.php/api/lineAction/gravida"];
    //    NSMutableDictionary *parameters=[NSMutableDictionary dictionary];
    //    parameters[@"uid"]=@"1";
    HttpRequest *httpRequest=[HttpRequest sharedInstance];
    [httpRequest postWithURLString:urlString parameters:nil success:^(id responseObject)
     {
         id json = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
         //获取数组
         json_Array=[json objectForKey:@"data"];
         if (json_Array.count>0)
         {
             allActivity *aa=[allActivity shardeManager];
             aa.num=4;
//             [self increaseProgress];
             [self dismiss];
//              [self changeArray:json_Array];
//             [self createTableViewFromVC:@"4"];
         }
//         NSLog(@"json=%@",json);
     } failure:^(NSError *error) {
         NSLog(@"error=%@",error);
     }];
    
}
- (void)increaseProgress
{
    progress += 0.05f;
    [SVProgressHUD showProgress:progress status:@"加载中..."];
    
    if(progress < 1.0f){
        [self performSelector:@selector(increaseProgress) withObject:nil afterDelay:0.1f];
    } else {
        [self performSelector:@selector(dismiss) withObject:nil afterDelay:0.4f];
    }
}
- (void)dismiss {
    [SVProgressHUD dismiss];
    [self changeArray:json_Array];
    [self createTableViewFromVC:@"4"];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
